<template>
  <div class="container" id="pdfDom">
    <!-- 头部 -->
    <div class="head">
      <div class="head-title">个人简历</div>
      <div class="head-line">|</div>
      <div class="head-content">
        <div>细心从每一个小细节开始</div>
        <div>Personal resume</div>
      </div>

      <div class="icon">
        <svg-icon name="library"></svg-icon>
        <svg-icon name="bag"></svg-icon>
        <svg-icon name="pencil"></svg-icon>
      </div>
    </div>

    <img :src="stripImg" alt="图片" class="img-strip" />
    <!-- 内容区 -->
    <div class="content">
      <!-- 个人信息 -->
      <div class="content-list">
        <img :src="dividerImg" alt="" />
        <div class="content-list-title">基础信息</div>
        <div class="content-list-info">
          <div class="content-list-info-left">
            <div class="font" style="font-size: 20px; color: black">
              姓 名:{{ studentInfo.name }}
            </div>
            <div class="font" style="font-size: 20px; color: black">
              年 龄:{{ studentInfo.age }}
            </div>
            <div class="font" style="font-size: 20px; color: black">
              电 话:{{ studentInfo.phone }}
            </div>
            <div class="font" style="font-size: 20px; color: black">
              邮 箱:{{ studentInfo.email }}
            </div>
          </div>
          <div class="avatar">
            <img src="@/assets/imgs/resume/avatar.jpg" alt="" />
          </div>
        </div>
      </div>

      <!-- 教育经历 -->
      <div class="content-list">
        <img :src="dividerImg" alt="" />
        <div class="content-list-title">教育经历</div>
        <div class="content-list-info" style="font-size: 20px; color: black">
          {{ studentInfo.educational_experience }}
        </div>
      </div>

      <!-- 专业技能 -->
      <div class="content-list">
        <img :src="dividerImg" alt="" />
        <div class="content-list-title">专业技能</div>
        <div class="content-list-info" style="font-size: 20px; color: black">
          {{ studentInfo.skill }}
        </div>
      </div>

      <!-- 项目经历 -->
      <div class="content-list">
        <img :src="dividerImg" alt="" />
        <div class="content-list-title">项目经历</div>
        <div class="content-list-info" style="font-size: 20px; color: black">
          {{ studentInfo.project_experience }}
        </div>
      </div>

      <!-- 职位和薪水 -->
      <div class="content-list">
        <img :src="dividerImg" alt="" />
        <div class="content-list-title">职位和薪水</div>
        <div class="content-list-info">
          <div class="position_salary">
            <n-space vertical>
              <div style="font-size: 20px; color: black">
                期望职位： {{ studentInfo.dream_position }}
              </div>
              <div style="font-size: 20px; color: black">
                期望薪资： {{ studentInfo.dream_salary }}
              </div>
            </n-space>
          </div>
        </div>
      </div>

      <!-- 自我评价 -->
      <div class="content-list">
        <img :src="dividerImg" alt="" />
        <div class="content-list-title">自我评价</div>
        <div class="content-list-info">
          <div class="self_evaluation">
            <span> {{ studentInfo.self_evaluation }}</span>
          </div>
        </div>
      </div>
    </div>
    <div class="btn">
      <n-button type="primary" @click="exportPDF" :class="{ isShow }"
        >导出PDF</n-button
      >
      <n-button type="info" @click="sendEmail" :class="{ isShow }"
        >发送邮件</n-button
      >
    </div>
  </div>
</template>

<script setup>
//引入发送邮件接口
import { sendEmailAPI, getStudentResumeAPI } from "@/http/api/company"
import htmlToPdf from "@/plugins/htmlToPdf"
import { ref, onMounted, computed } from "vue"
import { useRoute, useRouter } from "vue-router"

const route = useRoute()
const router = useRouter()

// 定义属性
let isShow = ref(false)
const stripImg = ref(require("@/assets/imgs/resume/resume-strip.png"))
const dividerImg = ref(require("@/assets/imgs/resume/resume-divider.png"))
const studentInfo = ref({})
const avatar = ref()
const uid = ref()

// 定义方法
const exportPDF = () => {
  isShow.value = !isShow.value
  htmlToPdf.getPdf("个人简历")
}

//获取学生个人信息
const getInfo = () => {
  const data = {
    id: route.params.uid,
    cid: route.params.cid,
    apply_job: route.params.jobname,
  }
  // console.log("用户获取学生简历信息", data)
  getStudentResumeAPI(data)
    .then((result) => {
      // console.log(result)
      studentInfo.value = result.result[0]
    })
    .catch((err) => {
      console.log(err)
    })
}

//发送邮件的方法
const sendEmail = () => {
  const data = {
    id: route.params.uid,
    cid: route.params.cid,
    apply_job: route.params.jobname,
  }
  sendEmailAPI(data)
    .then((result) => {
      if (result.status == true) {
        window.$message.success("邮件发送成功")
      }
    })
    .catch((err) => {
      console.log(err)
    })
  // console.log("触发")
}

// 生命周期钩子
onMounted(() => {
  getInfo()
})
</script>

<style lang="scss" scoped>
.btn {
  display: flex;
  justify-content: space-around;
}
#pdfDom {
}

.isShow {
  display: none;
}

.container {
  width: 90%;
  padding: 20px 15px;
  background-color: #fff;
  .head {
    width: 95%;
    height: 80px;
    display: flex;
    .head-title {
      margin-top: 10px;
      font-size: 38px;
      font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
      color: #2c4d79;
    }

    .head-line {
      margin: 0px 10px;
      font-size: 50px;
    }

    .head-content {
      font-size: 25px;
      div {
      }
    }

    .icon {
      margin-left: 220px;
      width: 300px;
      height: 300px;
      display: flex;
      justify-content: space-around;
      .svg-icon {
        width: 30px;
        height: 30px;
        padding: 10px;
        border-radius: 50%;
        background-color: #d2b48c;
        // border: 1px solid #f5f5f5;
        font-size: 35px;
      }
    }
  }

  .img-strip {
    width: 100%;
    height: 10px;
    margin-bottom: 22px;
  }

  .content {
    .content-list {
      position: relative;
      img {
        width: 100%;
        height: 40px;
      }
      .content-list-title {
        position: absolute;
        top: 8px;
        left: 55px;
      }

      .content-list-info {
        width: 98%;
        height: 100px;
        // background-color: aqua;
        display: flex;
        margin: 10px;
        justify-content: space-between; /* 横向中间自动空间 */
        border: 1px solid black;
        border-radius: 5px;

        .content-list-info-left {
          display: flex;
          flex-direction: column;
          justify-content: space-around;
          padding: 15px;
          .font {
            font-size: 18px;
            margin: 2px;
          }
        }
        .avatar {
          width: 80px;
          height: 100px;
          background-color: #d2b48c;
          margin-right: 30px;

          img {
            object-fit: fill;
            width: 80px;
            height: 100px;
          }
        }
      }
    }
    .content-list {
      img {
      }
      .content-list-title {
      }
      .content-list-info {
      }
    }
    .content-list {
      img {
      }
      .content-list-title {
      }
      .content-list-info {
      }
    }
    .content-list {
      img {
      }
      .content-list-title {
      }
      .content-list-info {
      }
    }
    .content-list {
      img {
      }
      .content-list-title {
      }
      .content-list-info {
        .position_salary {
          div {
          }
        }
      }
    }
    .content-list {
      img {
      }
      .content-list-title {
      }
      .content-list-info {
        .self_evaluation {
          font-size: 20px;
          color: black;
        }
      }
    }
  }
  .btn {
  }
}
</style>
